#pragma  once

struct GridLayerQuadVertex
{
	float pos[2];
	float coord[4];
	float offsetCoords[4];
};

struct GridLayerBoundEdge
{
	float pos1[2];
	float pos2[2];

	float coord1[2];
	float coord2[2];

	float normal[2];
};

class GridLayer
{
public:
	GridLayer(int res_m, int res_n, int res_l, int l, int numTilesX, int numTilesY, int rownum, int columnum);
	~GridLayer(void);

	//renders an inner layer
	void DrawQuad(float z = 0);
	//renders the boundary edges of an inner layer
	void DrawBounds(float z = 0);

	int rowNum, columnNum;

protected:
	int res_m;
	int res_n;
	int res_l;
	int l;

	//Flat3D coordinates of the lower left and upper right corner of the upper neighbor slice
	float UpperLayerOffset[2];
	//Flat3D coordinates of the lower left and upper right corner of the lower neighbor slice
	float LowerLayerOffset[2];
	//Flat3D coordinates of the lower left and upper right corner of the quad
	float MinCoord[2];
	float MaxCoord[2];
	//window space position of the lower left and upper right corner of the quad
	float MinPos[2];
	float MaxPos[2];

	GridLayerQuadVertex quadVertices[4];
	GridLayerBoundEdge boundEdges[4];
};

class BoundaryLayer
{
protected:
	int res_m;
	int res_n;
	int res_l;
	bool up;
	//Flat3D coordinates of the lower left and upper right corner of the quad
	float MinCoord[2];
	float MaxCoord[2];
	//window space position of the lower left and upper right corner of the quad
	float MinPos[2];
	float MaxPos[2];
	//Flat3D coordinates of the lower left and upper right corner of the neighnoring inner slice
	float NextLayerOffset[2];

	GridLayerQuadVertex quadVertices[4];

public:
	BoundaryLayer(int res_m, int res_n, int res_l, bool up, int numTilesX, int numTilesY);
	//renders a boundary layer
	void DrawQuad(float z = 0);

	int rowNum, columnNum;
};